package com.tanhua.server.controller;

import cn.hutool.db.PageResult;
import com.tanhua.model.vo.PageResultVo;
import com.tanhua.server.service.SmallVideosService;
import javafx.beans.property.ReadOnlySetProperty;
import org.aspectj.weaver.ResolvedPointcutDefinition;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @Description: test
 * @Create by: JJ菜菜
 * @Date: 2021/12/7 22:25
 */
@RequestMapping("/smallVideos")
@RestController
public class SmallVideosController {


    @Autowired
    private SmallVideosService smallVideosService;

    /**
     * 发布小视频
     * @param videoThumbnail
     * @param videoFile
     * @return
     */
    @PostMapping
    public ResponseEntity smallVideos(MultipartFile videoThumbnail, MultipartFile videoFile) throws IOException {

        smallVideosService.saveVideos(videoThumbnail, videoFile);
        return ResponseEntity.ok(null);
    }

    /**
     * 视频列表
     */
    @GetMapping
    public ResponseEntity queryVideoList(@RequestParam(defaultValue = "1")  Integer page,
                                         @RequestParam(defaultValue = "10") Integer pagesize) {
        PageResultVo result = smallVideosService.queryVideoList(page, pagesize);
        return ResponseEntity.ok(result);
    }

}
